home *** CD-ROM | disk | FTP | other *** search
- #pragma once
- //
- // 941006: testing this code for the first time in a long time. It appears
- // that one needs an instance of a 'window' or a 'fullscreen' before one
- // can create a 'gworld'. If one does:
- //
- // gworld earth;
- // window broken;
- //
- // the Mac crashes inside a 'ShowWindow' call in window:: window
- // I don't have time to study this in full, but I suspect that 'gworld::gworld'
- // somehow is buggy. Alternatively there is a bug in the System (possibly only
- // in system 7.5) which precludes the use of GWorlds without the use of windows.
- // It also might be a bug in the Think Debugger (7.0.4), since an application
- // I wrote to test this hypothesis did not hang.
- //
- class gworld : public port
- {
- public:
- //
- // the first constructor is especially made for creating a backing-store
- // to blit to the port specified.
- //
- gworld( int breedte, int hoogte, int diepte, port &original);
-
- gworld( int breedte = 320, int hoogte = 200, int diepte = 8, CTabHandle cTable = nil);
- ~gworld();
-
- int diepte() const;
-
- void fill_random() const;
- //
- // two_bit_merge only works on a gworld of depth 2,
- // and must receive two parameters of depth 1.
- // (I should device subclasses for this, but I don't have time to do that)
- //
- void two_bit_merge( const gworld &left, const gworld &right) const;
- //
- // dump and load do not do extensive error checking
- //
- OSErr dump( short defile) const;
- OSErr load( short defile) const;
-
- private:
- int de_diepte;
-
- static unsigned short extendChar( const unsigned char theChar);
- static const unsigned short extensions[ 256];
- };
-
- inline int gworld::diepte() const
- {
- return de_diepte;
- }
- //
- // This routine was bootstrapped from a slower 4-bit-at-a-time version
- // with the following program:
- //
- // void main( int argc, char *argv[])
- // {
- // argc = ccommand( &argv); // for THINK C
- // for( int i = 0; i < 256; i++)
- // {
- // unsigned short result = extendCharSlow( i);
- // printf( "0x%04X", result);
- // if( (i % 8) == 7)
- // {
- // printf( ",\n");
- // } else {
- // printf( ", ");
- // }
- // }
- // }
- //
- // unsigned short extendCharSlow( const unsigned char theChar)
- // {
- // static const unsigned short extensions[ 16] =
- // {
- // 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F,
- // 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF
- // };
- // return (extensions[ theChar >> 4] << 8) + extensions[ theChar & 0x0F];
- // }
- //
- // Converting to a 16-bit-at-a-time version is deemed impractical.
- // 941116: We could, of course do this at runtime with a static member,
- // and a funtion which fills the large table at startup. It only would be
- // a 64K table of unsigned longs, or 256K.
- // Before embarking on this voyage one would have to check that making
- // 'two_bit_merge' faster by a factor of two would improve the program. The
- // current version of 'StereoMovie' is fast enough for our purposes, and that
- // check has never been made, so we do not yet use such a large buffer.
- // Also, a processor cache smaller than 256K might make use of such a large
- // table slower than expected.
- //
- inline unsigned short gworld::extendChar( const unsigned char theChar)
- {
- return extensions[ theChar];
- }
-